package Com;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.jasper.servlet.JasperLoader;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperManager;
import net.sf.jasperreports.engine.JasperPrint;

public class Relatorio extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		Banco banco = new Banco();
		banco.Oracle();
		String pathJasper = getServletContext().getRealPath("/WEB-INF/com/relatorios/")+ "/";
		String path = getServletContext().getRealPath("/");
		Map parametros = new HashMap();
		parametros.put("PathClientes", pathJasper);
		try {
			JasperPrint impressao = JasperFillManager.fillReport(pathJasper + "Clientes.jasper", parametros,banco.Oracle());
			//JasperManager.printReportToPdfFile(impressao, path + "/Clientes.pdf");
			//JasperManager.printReportToPdfFile(impressao, path + "/Clientes.pdf");
			resp.sendRedirect("Clientes.pdf");
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		// TODO Auto-generated method stub
		//super.doPost(req, resp);
	}

}
